package io.renren.common.response;

import java.util.UUID;

/**
 * 分拣系统需求字段
 * create by znr48268 on 2018/12/11
 */
public class Response {

    String ts;

    int result;
    String resultText;

    String method;
    Object data;

    public Response(int result, String resultText, Object data) {
        this.result = result;
        this.resultText = resultText;
        this.data = data;
    }

    public static void main(String[] args) {
        System.out.println(UUID.randomUUID().toString());
    }

    public String getTs() {
        return ts;
    }

    public void setTs(String ts) {
        this.ts = ts;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public String getResultText() {
        return resultText;
    }

    public void setResultText(String resultText) {
        this.resultText = resultText;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Response ok() {
        return new Response(1, "success", null);
    }

    public static Response ok(Object data) {
        return new Response(1, "success", data);
    }

    public static Response fail() {
        return new Response(-1, "系统异常，请联系管理员", null);
    }

    public static Response fail(String error) {
        return new Response(-1, error, null);
    }

    public static Response fail(Exception error) {
        return new Response(-1, error.getMessage(), null);
    }

}
